package com.tjbklx1.thread.chap01.ext;

import java.util.Random;

public class UserThread extends Thread {

	private final static Random random = new Random(314159);
	private final BoundedResource resource;

	public UserThread(BoundedResource resource) {
		this.resource = resource;
	}

	@Override
	public void run() {
		try {
			while (true) {
				resource.use();
				Thread.sleep(random.nextInt(3000));
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
